SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

alter  procedure p_modifyabatebillsuramt (  
  @actype int,  
  @btype  int,  
  @bid    int,  
  @amount decimal(18,2),
  @dcamount decimal(18,2)
)  as  
  
declare @sql nvarchar(500),  
        @tab varchar(64)  
begin  
  set nocount on  
  if (@btype is null or @bid is null) return  
  
  select @tab=btable from ts_billset where bid=@btype  
  set @sql = N'update ' + @tab + N' set relationsuramt=relationsuramt+@actype*@amount, dcrelationsuramt=dcrelationsuramt+@actype*@dcamount ' +  
             N'where bid=@bid'  
  
  exec sp_executesql @sql,N'@actype int, @bid int,@amount decimal(18,2),@dcamount decimal(18,2)',  
                     @actype, @bid, @amount, @dcamount  
end  
  
  
  


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

